{include file="public/head"}
<div class="main">
    {include file="public/left"}
    <div class="middle">
    {include file="public/header"}
    <div class='userinfo'>
        {include file="public/userleft"}
        <div class="pub_task">
            <ul class="layui-tab-title">
                <i id="left" class="layui-icon">&#xe603;</i>
                <div>
                    <li data-target="0" class="layui-this">{:__('全部')}</li>
                    <li data-target="1">{:__('充值')}</li>
                    <li data-target="2">{:__('提现')}</li>
                    <li data-target="3">{:__('悬赏扣除')}</li>
                    <li data-target="4">{:__('奖励')}</li>
                    <li data-target="5">{:__('退回')}</li>
                    <li data-target="6">{:__('平账')}</li>
                </div>
                <i id="right" class="layui-icon">&#xe602;</i>
            </ul>
            <ul class="task_table">
                <dl class='_money'>
                    <span>{:__('类型')}</span>
                    <span>{:__('用途')}</span>
                    <span>{:__('金币')}</span>
                    <span>{:__('剩余金币')}</span>
                    <span>{:__('时间')}</span>
                </dl>
                
            </ul>
        </div>
    </div>
    <div id="in_page" style="margin-left: 23%;"></div>
    {include file="public/foot"}
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}
<script>
    var status = '';
    noLog();

    var total = 0;
    function integrallog(newpage,status)
    {
        $.ajax({
            url:'/api/integral/index',
            type:'get',
            data:{'token':token,'page':newpage,'limit':5,op_type:status},
            success:function(ret){
                if(ret.code == 1){
                    $("._list").remove();
                    if(ret['data'] == '' && ret['data'] == null && ret['data'] == undefined){
                        return fasle;
                    }
                    if(ret['data']['ls'] == '' && ret['data']['ls'] == null && ret['data']['ls'] == undefined){
                        return fasle;
                    }
                    var htl = "";
                    var status = '';
                    for(i in ret['data']['ls']){
                        // if(ret['data']['ls'][i]['op_type'] == 1){
                        //     status = '{:__("充值")}';
                        // } else if(ret['data']['ls'][i]['op_type'] == 2){
                        //     status = '{:__("提现")}';
                        // } else if(ret['data']['ls'][i]['op_type'] == 3){
                        //     status = '{:__("悬赏扣除")}';
                        // } else if(ret['data']['ls'][i]['op_type'] == 4){
                        //     status = '{:__("奖励")}';
                        // } else if(ret['data']['ls'][i]['op_type'] == 5){
                        //     status = '{:__("退回")}';
                        // } else if(ret['data']['ls'][i]['op_type'] == 6){
                        //     status = '{:__("平账")}';
                        // }
                        if(ret['data']['ls'][i]['op_type_txt'] == null || ret['data']['ls'][i]['op_type_txt'] == undefined){
                            ret['data']['ls'][i]['op_type_txt'] = '';
                        }
                        if(ret['data']['ls'][i]['memo'] == null || ret['data']['ls'][i]['memo'] == undefined){
                            ret['data']['ls'][i]['memo'] = '';
                        }
                        htl += '<dl class="_list _money">'
                            +'<span>'+ret['data']['ls'][i]['op_type_txt']+'</span>'
                            +'<span>'+ret['data']['ls'][i]['memo']+'</span>'
                            +'<span>'+ret['data']['ls'][i]['money']+'</span>'
                            +'<span>'+ret['data']['ls'][i]['after']+'</span>'
                            +'<span>'+ret['data']['ls'][i]['create_time']+'</span>'
                            +'</dl>';
                    }
                    $(".task_table").append(htl);
                    total = ret['data']['total'];
                    if(newpage == 1){
                        pagechange();
                    }
                   
                } else if(ret.code != 401){
                    layer.msg(ret.msg,{icon:2});
                }
            }
        });
    }
    function pagechange()
    {
        //分页
        createpage('in_page',total,5,function(obj,first){
            var nowpage = obj.curr;
            if(!first){
                integrallog(nowpage,status);
            }
        });
    }
    $(document).queue('task',function(){
        integrallog(1,status);
    });
    $(document).dequeue('task');
    
    $(document).on("click",'.pub_task .layui-tab-title li',function(){
        var _this = $(this);
        status = _this.attr("data-target");
        if(status == 0){
            status = '';
        }
        integrallog(1,status);
    });
    // $("#left").click(function(){
    //     var left = parseInt($(".pub_task .layui-tab-title li").css("left"));
    //     if(left<0){
    //         left = left+3;
    //         $(".pub_task .layui-tab-title li").css("left",left+'px');
    //     }
    // });
    // $("#right").click(function(){
    //     var left = parseInt($(".pub_task .layui-tab-title li").css("left"));
    //     left = left-3;
    //     $(".pub_task .layui-tab-title li").css("left",left+'px');
    // });
    var nowtab = 0;
    var beforemove = [];
    $(document).on('click',"#right",function(){
        var lefttmp = $(this).siblings(".layui-tab-title div").scrollLeft();
        var move = $(this).siblings(".layui-tab-title div").find("li").eq(nowtab)[0].offsetWidth;
        left = parseInt(lefttmp)+(move+12);
        $(this).siblings(".layui-tab-title div").scrollLeft(left);
        var afterleft = $(this).siblings(".layui-tab-title div").scrollLeft();
        var canmove = parseInt(afterleft)-parseInt(lefttmp);
        if(canmove > 0){
            beforemove.push(canmove);
        }
        if(canmove > 0){
            nowtab++;
        }
        
    });
    $(document).on('click',"#left",function(){
        var left = $(this).siblings(".layui-tab-title div").scrollLeft();
        if(parseInt(left) <= 0){
            $(this).siblings(".layui-tab-title div").scrollLeft(0);
            nowtab = 0;
            return false;
        }
        // var move = $(this).siblings(".layui-tab-title").find("li").eq(nowtab-1)[0].offsetWidth;
        move = beforemove.pop();
        left = parseInt(left)-move;
        $(this).siblings(".layui-tab-title div").scrollLeft(left);
        nowtab--;
    });
</script>